package com.pubinfo.passbook.api.controller.auth;

import com.pubinfo.passbook.common.entity.*;
import com.pubinfo.passbook.common.model.dto.MDM.*;
import com.pubinfo.passbook.common.model.http.mdm.MdmResult;
import com.pubinfo.passbook.common.model.vo.base.MyPage;
import com.pubinfo.passbook.common.model.vo.mdm.SupplierCascadeBankVo;
import com.pubinfo.passbook.common.service.master.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(value = "mdm")
@Api(tags = "MDM数据管理")
@Slf4j
public class MdmController {
  @Autowired
  ITMdmAccountingTitleService accountingTitleService;
  @Autowired
  ITMdmAltAccountService altAccountService;
  @Autowired
  ITMdmBankAccountService bankAccountService;
  @Autowired
  ITMdmBankService bankService;
  @Autowired
  ITMdmCompanyService companyService;
  @Autowired
  ITMdmContractService contractService;
  @Autowired
  ITMdmCostCenterGroupService costCenterGroupService;
  @Autowired
  ITMdmCostCenterService costCenterService;
  @Autowired
  ITMdmProfitCenterGroupService profitCenterGroupService;
  @Autowired
  ITMdmProfitCenterService profitCenterService;
  @Autowired
  ITMdmSupplierService supplierService;
  
  @PostMapping("AccountingTitleList")
  @ApiOperation(value = "根据创建日期批量查询会计科目")
  public MdmResult<MyPage<TMdmAccountingTitle>> AccountingTitleList(@RequestBody MdmAccountingTitleParam paramObj) {
    return MdmResult.success(new MyPage(accountingTitleService.listMdmAccountingTitle(paramObj)));
  }
  
  @PostMapping("AccountingTitleById/{id}")
  @ApiOperation(value = "根据id查询会计科目")
  public MdmResult<TMdmAccountingTitle> AccountingTitleById(@PathVariable String id) {
    return MdmResult.success(accountingTitleService.getById(id));
  }
  
  @PostMapping("AltAccountList")
  @ApiOperation(value = "根据创建日期批量查询备选统驭科目")
  public MdmResult<MyPage<TMdmAltAccount>> AltAccountList(@RequestBody MdmAltAccountParam paramObj) {
    return MdmResult.success(new MyPage(altAccountService.listMdmAltAccount(paramObj)));
  }
  
  @PostMapping("AltAccountById/{id}")
  @ApiOperation(value = "根据id查询备选统驭科目")
  public MdmResult<TMdmAltAccount> AltAccountById(@PathVariable String id) {
    return MdmResult.success(altAccountService.getById(id));
  }
  
  @PostMapping("BankAccountList")
  @ApiOperation(value = "根据创建日期批量查询银行账户")
  public MdmResult<MyPage<TMdmBankAccount>> BankAccountList(@RequestBody MdmBankAccountParam paramObj) {
    return MdmResult.success(new MyPage(bankAccountService.listMdmBankAccount(paramObj)));
  }
  
  @PostMapping("BankAccountById/{id}")
  @ApiOperation(value = "根据id查询备银行账户")
  public MdmResult<TMdmBankAccount> BankAccountById(@PathVariable String id) {
    return MdmResult.success(bankAccountService.getById(id));
  }
  
  @PostMapping("BankList")
  @ApiOperation(value = "根据创建日期批量查询银行代码")
  public MdmResult<MyPage<TMdmBank>> BankList(@RequestBody MdmBankParam paramObj) {
    return MdmResult.success(new MyPage(bankService.listMdmBank(paramObj)));
  }
  
  @PostMapping("BankById/{id}")
  @ApiOperation(value = "根据id查询备银行代码")
  public MdmResult<TMdmBank> BankById(@PathVariable String id) {
    return MdmResult.success(bankService.getById(id));
  }
  
  @PostMapping("CompanyList")
  @ApiOperation(value = "根据创建日期批量查询公司代码")
  public MdmResult<MyPage<TMdmCompany>> CompanyList(@RequestBody MdmCompanyParam paramObj) {
    return MdmResult.success(new MyPage(companyService.listMdmCompany(paramObj)));
  }
  
  @PostMapping("CompanyById/{id}")
  @ApiOperation(value = "根据id查询备公司代码")
  public MdmResult<TMdmCompany> CompanyById(@PathVariable String id) {
    return MdmResult.success(companyService.getById(id));
  }
  
  @PostMapping("ContractList")
  @ApiOperation(value = "根据创建日期批量查询合同")
  public MdmResult<MyPage<TMdmContract>> ContractList(@RequestBody MdmContractParam paramObj) {
    return MdmResult.success(new MyPage(contractService.listMdmContract(paramObj)));
  }
  
  @PostMapping("ContractById/{id}")
  @ApiOperation(value = "根据id查询备合同")
  public MdmResult<TMdmContract> ContractById(@PathVariable String id) {
    return MdmResult.success(contractService.getById(id));
  }
  
  @PostMapping("CostCenterGroupList")
  @ApiOperation(value = "根据创建日期批量查询成本中心组")
  public MdmResult<MyPage<TMdmCostCenterGroup>> CostCenterGroupList(@RequestBody MdmCostCenterGroupParam paramObj) {
    return MdmResult.success(new MyPage(costCenterGroupService.listMdmCostCenterGroup(paramObj)));
  }
  
  @PostMapping("CostCenterGroupById/{id}")
  @ApiOperation(value = "根据id查询备成本中心组")
  public MdmResult<TMdmCostCenterGroup> CostCenterGroupById(@PathVariable String id) {
    return MdmResult.success(costCenterGroupService.getById(id));
  }
  
  @PostMapping("CostCenterList")
  @ApiOperation(value = "根据创建日期批量查询成本中心")
  public MdmResult<MyPage<TMdmCostCenterGroup>> CostCenterList(@RequestBody MdmCostCenterParam paramObj) {
    return MdmResult.success(new MyPage(costCenterService.selectMdmCostCenter(paramObj)));
  }
  
  @PostMapping("CostCenterById/{id}")
  @ApiOperation(value = "根据id查询备成本中心")
  public MdmResult<TMdmCostCenter> CostCenterById(@PathVariable String id) {
    return MdmResult.success(costCenterService.getById(id));
  }
  
  @PostMapping("ProfitCenterGroupList")
  @ApiOperation(value = "根据创建日期批量查询利润中心组")
  public MdmResult<MyPage<TMdmProfitCenterGroup>> ProfitCenterGroupList(@RequestBody MdmProfitCenterGroupParam paramObj) {
    return MdmResult.success(new MyPage(profitCenterGroupService.listMdmProfitCenterGroup(paramObj)));
  }
  
  @PostMapping("ProfitCenterGroupById/{id}")
  @ApiOperation(value = "根据id查询备利润中心组")
  public MdmResult<TMdmProfitCenterGroup> ProfitCenterGroupById(@PathVariable String id) {
    return MdmResult.success(profitCenterGroupService.getById(id));
  }
  
  @PostMapping("ProfitCenterList")
  @ApiOperation(value = "根据创建日期批量查询利润中心")
  public MdmResult<MyPage<TMdmProfitCenter>> ProfitCenterList(@RequestBody MdmProfitCenterParam paramObj) {
    return MdmResult.success(new MyPage(profitCenterService.listMdmProfitCenter(paramObj)));
  }
  
  @PostMapping("ProfitCenterById/{id}")
  @ApiOperation(value = "根据id查询备利润中心")
  public MdmResult<TMdmProfitCenter> ProfitCenterById(@PathVariable String id) {
    return MdmResult.success(profitCenterService.getById(id));
  }
  
  @PostMapping("SupplierList")
  @ApiOperation(value = "根据创建日期批量查询供应商")
  public MdmResult<MyPage<TMdmProfitCenter>> SupplierList(@RequestBody MdmSapSupplierParam paramObj) {
    return MdmResult.success(new MyPage(supplierService.selectSupplier(paramObj)));
  }
  
  @PostMapping("SupplierById/{id}")
  @ApiOperation(value = "根据id查询备供应商")
  public MdmResult<TMdmSupplier> SupplierById(@PathVariable String id) {
    return MdmResult.success(supplierService.getById(id));
  }
  
  @PostMapping("SupplierCascadeSelect")
  @ApiOperation(value = "供应商级联查询银行信息")
  public MdmResult<MyPage<SupplierCascadeBankVo>> selectSupplierCascadeBank(@RequestBody SupplierCascadeBankParam param) {
    return MdmResult.success(supplierService.selectSupplierCascadeBank(param));
  }
}
